package tools;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageFilter;
import java.awt.image.ImageProducer;
import java.awt.image.RGBImageFilter;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import javax.imageio.ImageIO;

import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

public class ImageFactory {

	private static ImageFactory imageFactory;
	
	public static ImageFactory getInstance() {
		if(imageFactory == null) {
			imageFactory = new ImageFactory();
		}
		return imageFactory;
	}
	
	private ImageFactory() {

	}

	public List<Image> splitImg(String path, int width, int height) {

		List<Image> tileList = new ArrayList<Image>();

		Image bigImage = null;
		try {
			bigImage = new Image(path);
		} catch (SlickException e) {
			e.printStackTrace();
		}


		for (int y = 0; y < bigImage.getHeight(); y = y + height) {

			for (int x = 0; x < bigImage.getWidth(); x = x + width) {

				tileList.add(bigImage.getSubImage(x, y, width, height));

			}

		}

		return tileList;

	}

	

}
